package com.qys.livesMall.financial.controller.app;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qys.livesMall.common.result.R;
import com.qys.livesMall.financial.model.vo.app.AppFinancialOfflinePageVO;
import com.qys.livesMall.financial.service.FinancialOfflineService;
import com.qys.livesMall.framework.view.BaseQuery;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 线下理财 前端控制器
 * </p>
 *
 * @author
 * @since 2023-06-10
 */
@RestController
@Tag(name = "APP-线下理财")
@RequestMapping("/app/financial/offline")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class AppFinancialOfflineController {

    private final FinancialOfflineService financialOfflineService;

    @PostMapping("/page")
    @Operation(summary = "分页查询线下理财信息")
    public R<Page<AppFinancialOfflinePageVO>> page(@RequestBody BaseQuery baseQuery) {
        return R.ok(financialOfflineService.pageByApp(baseQuery));
    }

    @GetMapping("/check/{offlineId}")
    @Operation(
            summary = "线下理财权限校验",
            parameters = {
                    @Parameter(name = "offlineId", description = "理财id")
            }
    )
    public R<Void> checkPromise(@PathVariable Long offlineId) {
        financialOfflineService.checkPromiseByApp(offlineId);
        return R.ok();
    }
}
